
cc.Class({
    extends: require('UI-PanelWindow'),

    properties: {
    },
    onLoad(){
        this._super();
        cc.find('view/revert/reverse1/reverse',this.node).runAction(cc.repeatForever(cc.rotateBy(1,360)))
    },
    onClick(e,d){
        if(d=='0'){
            this.pauseTime = 4;
            cc.find('view/pause',this.node).active = false;
            cc.find('view/revert',this.node).active = true;
            this.schedule(this.startRevert,1.0,3);
            this.startRevert();
            SoundMgr.playSound('Audio/count');
            this.scheduleOnce(function(){
                console.log('声音恢复')
                cc.audioEngine.resumeAll();
            },3)
        } else {
            global.usedFullLevel=false;
            global.Data.prop2=false;
            global.gaming=false;
            global.Data.isFirst=false
            cc.isPauseGame = false;
            global.UIMgr.popUI();
            global.GameLoop.enterSelectPlane();
        }
    },
    startRevert(){
        this.pauseTime--;
        if(this.pauseTime === 0){
            global.UIMgr.popUI();

            global.GameLoop.GameMgr.resumeGame();
            this.revertCb&&this.revertCb();
            
            return;
        }
        var panel = cc.find('view/revert/reverse1',this.node);
        panel.getChildByName('1').active = this.pauseTime == 1;
        panel.getChildByName('2').active = this.pauseTime == 2;
        panel.getChildByName('3').active = this.pauseTime == 3;
    },
    setOptions(option){
        if(option.revert){
            this.revertCb = option.cb;
            this.pauseTime = 4;
            cc.find('view/pause',this.node).active = false;
            cc.find('view/revert',this.node).active = true;
            this.schedule(this.startRevert,1.0,3);
            this.startRevert();
        } else {
            cc.find('view/pause',this.node).active = true;
            cc.find('view/revert',this.node).active = false;
        }
    }

    // update (dt) {},
});
